# -*- coding: utf-8 -*-
# @Time    : 18-6-30 下午3:07
# @Author  : hp
# @Email   : shaoeric@foxmail.com

from flask import session, redirect, url_for, g
from functools import wraps
import config


def login_required(func):
    @wraps(func)
    def inner(*args, **kwargs):
        if config.CMS_USER_ID in session:
            return func(*args, **kwargs)
        else:
            return redirect(url_for("cms.login"))
    return inner
